package com.fzhucc.modules.security.domain.bo

import com.fzhucc.modules.security.domain.dto.JwtUserDto
import org.springframework.security.authentication.AbstractAuthenticationToken
import org.springframework.security.core.GrantedAuthority

/**
 * @author Woolsen
 */
class WxAuthenticationToken : AbstractAuthenticationToken {

    val user: JwtUserDto

    constructor(
        user: JwtUserDto,
        authorities: Collection<GrantedAuthority>,
    ) : super(authorities) {
        this.user = user
        isAuthenticated = true
    }

    constructor(user: JwtUserDto) : super(null) {
        this.user = user
    }

    override fun getCredentials(): Any {
        return user.password
    }

    override fun getPrincipal(): JwtUserDto {
        return user
    }
}